package classwork.demo3;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class day2 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");

        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db2", "root", "root");

        if(conn==null){
            System.out.println("连接失败！");
        }else{
            System.out.println("连接成功！");

            Statement st = conn.createStatement();
            String sql ="insert into stu values('4','老火','3333')";

            if(st.executeUpdate(sql)>=1){
                System.out.println("插入成功！");
            }else{
                System.out.println("插入失败！");
            }
            conn.close();
        }
    }
}
